//定义store
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useUserAddressAPI } from '@/apis/user'
export const useAddressStore = defineStore('address', () => {

    const addressList = ref({})


    //action
    const getAddressInfo = async () => {

        const res = await useUserAddressAPI()
        console.log(res);
        addressList.value = res.data;
    }

    //清除地址信息的action 
    const clearAddressInfo = async () => {
        addressList.value = {}
    }

    return {
        addressList,
        getAddressInfo,
        clearAddressInfo
    }
}, {
    persist: true//持久化存储
})